package com.aaa.bookproject.service.impl;

import com.aaa.bookproject.entity.TBook;
import com.aaa.bookproject.dao.TBookMapper;
import com.aaa.bookproject.service.ITBookService;
import com.aaa.bookproject.util.PageUtil;
import com.aaa.bookproject.util.ResultData;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author LvYongQi
 * @since 2021-05-09
 */
@Service
public class TBookServiceImpl extends ServiceImpl<TBookMapper, TBook> implements ITBookService {

    @Resource
    private TBookMapper bookMapper;

    ResultData resultData = new ResultData();
    @Override
    public ResultData findBookAndType(PageUtil pageUtil) {
        PageHelper.startPage(pageUtil.getCurrentPage(),pageUtil.getPagesize());
        List<Map> bookAndType = bookMapper.findBookAndType(pageUtil);
        PageInfo<Map> bookPageInfo = new PageInfo<>(bookAndType);
        resultData.setData(bookPageInfo);
        return resultData;
    }
}
